<html> 
<head> 
<title> </title>
<style> 
px {font-family: "Lucida Console", Monaco }
p { font-size:100%; line-height:1.1em; }
body {xfont-style: sans-serif}
body {
color:#333; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:1em; line-height:1.3em; }
a:visited { color:#666; }
h1,h2,h3,h4,h5,h6 { color:#333; font-family:georgia, verdana, sans-serif; }
h1 { font-size:150%; page-break-before:auto;background-color: #aaaaff}
h2 { font-size:143%;color:teal; }
h3 { font-size:134%;color:blue; }
h4 { font-size:120%;color:gray; }
img { max-width: 55em}
p{ padding: 0;margin:0; }
p{ padding-right:1.4em; }
p{ padding-bottom:0.1em; }
p{ padding-top:1em; }
p{ whitespace: pre-wrap; }
h5,h6 { font-size:100% }
a.nav,a:link.nav, a:visited.nav { background-color:#FFF; color:#000; }
XXtable { border:double #000; border-collapse:collapse; }
XXtable { border-collapse:collapse; }
XXtd { border:thin solid #888; }
XXtd { border:none; }
li { margin-bottom:0.5em; }
blockquote { display:block; font-size:100%; line-height:1.1em; margin:0 0 0.5em; padding:0 2.5em; }
pre { background-color:#DDD; font-size:100%; overflow:auto; padding:1em; }
a,li span { color:#000; }
a:hover, a.nav:hover, a:hover math { background-color:#000; color:#FFF; }
#Container { margin:0 10px; text-align:center; background-color: #BBB}
#Content { border-top:none; margin:auto; padding:0.3em; text-align:left; width:100%; max-width:55em; background:#FFF}
span.webName { font-size:.5em; }
textarea#content { font-size: 1em; line-height: 1.125; }
h1#pageName { line-height:1em; margin:0.2em 0 0.2em 0; padding:0; }
.property { color:#666; font-size:100%; }
a.existingWikiWord[title]{ //border: 1px dashed #BBB; }
.byline { color:#666; font-size:1.0em; font-style:italic; margin-bottom:1em; padding-top:1px; } 
</style> 
</head>
<BODY bgcolor=#F0F0F0 text=#000000 link=#0000ff vlink=#C000C0 alink=#ff0000><A NAME=top></A>
<h5><a href="https://github.com/urbanjost/M_strings">[UP]</a></h5>
<div id="Container">
<div id="Content">
<CENTER>
<H1><HR><I>Manual Reference Pages &nbsp;-&nbsp;</I><NOBR>isnumber (3m_strings)</NOBR><HR></H1>
</CENTER>
<A name=0>

     <H3>NAME</H3>

</A>
<BLOCKQUOTE>
<B>isnumber</B>(3f) - [M_strings:NUMERIC] determine if a string represents a number
(LICENSE:PD)
<P>
</BLOCKQUOTE>
<A name=contents></A><H3>CONTENTS</H3></A>
<BLOCKQUOTE>
<A HREF=#1>Synopsis</A><BR>
<A HREF=#2>Description</A><BR>
<A HREF=#3>Options</A><BR>
<A HREF=#4>Returns</A><BR>
<A HREF=#5>Examples</A><BR>
<A HREF=#6>Author</A><BR>
<A HREF=#7>License</A><BR>
</BLOCKQUOTE>
<A name=8>

     <H3>SYNOPSIS</H3>

</A>
<BLOCKQUOTE>
function <B>isnumber</B>(str,msg)
<P>
<PRE>
    character(len=*),intent(in)  :: str
    character(len=:),intent(out),allocatable,optional  :: msg
<P>
</PRE>
</BLOCKQUOTE>
<A name=2>

     <H3>DESCRIPTION</H3>

</A>
<BLOCKQUOTE>
<B>ISNUMBER</B>(3f) returns a value greater than zero if the string represents
a number, and a number less than or equal to zero if it is a bad number.
Blank characters are ignored.
</BLOCKQUOTE>
<A name=3>

     <H3>OPTIONS</H3>

</A>
<BLOCKQUOTE>
<TABLE cellpadding=3>
<TR valign=top><TD width=6% nowrap>
<B>str</B> </TD><TD valign=bottom>
the string to evaluate as to whether it represents a numeric value
or not
</TD></TR>
<TR valign=top><TD width=6% nowrap>
<B>msg</B> </TD><TD valign=bottom>
An optional message describing the string
</TD></TR>
<TR></TR></TABLE></BLOCKQUOTE>
<A name=4>

     <H3>RETURNS</H3>

</A>
<BLOCKQUOTE>
<TABLE cellpadding=3>
<TR valign=top><TD colspan=2>
<B>isnumber</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
the following values are returned
<TABLE width=100% cellpadding=3><!-- tsb: the following values are returned
 -->
<TR></TR><TR></TR>
<TR valign=top><TD colspan=2>
<B>1 for an integer</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
[-+]NNNNN
</TD></TR>
<TR valign=top><TD colspan=2>
<B>2 for a whole number</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
[-+]NNNNN.
</TD></TR>
<TR valign=top><TD colspan=2>
<B>3 for a real value</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
[-+]NNNNN.MMMM
</TD></TR>
<TR valign=top><TD colspan=2>
<B>4 for a exponential value</B> </TD></TR><TR valign=top><TD width=6%>&nbsp;</TD><TD>
[-+]NNNNN.MMMM[-+]LLLL
[-+]NNNNN.MMMM[ed][-+]LLLL
</TD></TR>
<TR></TR></TABLE><!-- .PP -->
</TD></TR>
<TR></TR></TABLE>values less than 1 represent an error
</BLOCKQUOTE>
<A name=5>

     <H3>EXAMPLES</H3>

</A>
<BLOCKQUOTE>
As the example shows, you can use an internal <B>READ</B>(3f) along with the
IOSTAT= parameter to check (and read) a string as well.
<P>
<PRE>
    program demo_isnumber
    use M_strings, only : isnumber
    implicit none
    character(len=256) :: line
    real               :: value
    integer            :: ios1, ios2
    integer            :: answer
    character(len=256) :: message
    character(len=:),allocatable :: description
       write(*,*)&#146;Begin entering values, one per line&#146;
       do
          read(*,&#146;(a)&#146;,iostat=ios1)line
          !
          ! try string as number using list-directed input
          line=&#146;&#146;
          read(line,*,iostat=ios2,iomsg=message) value
          if(ios2.eq.0)then
             write(*,*)&#146;VALUE=&#146;,value
          elseif( is_iostat_end(ios1) ) then
             stop &#146;end of file&#146;
          else
             write(*,*)&#146;ERROR:&#146;,ios2,trim(message)
          endif
          !
          ! try string using isnumber(3f)
          answer=isnumber(line,msg=description)
          if(answer.gt.0)then
             write(*,*) &
             & &#146; for &#146;,trim(line),&#146; &#146;,answer,&#146;:&#146;,description
          else
             write(*,*) &
             & &#146; ERROR for &#146;,trim(line),&#146; &#146;,answer,&#146;:&#146;,description
          endif
          !
       enddo
    end program demo_isnumber
<P>
</PRE>
</BLOCKQUOTE>
Example run
<P>
<PRE>
   &gt; Begin entering values
   &gt; ERROR:          -1 End of file
   &gt;  ERROR for            -1 :null string
   &gt;10
   &gt; VALUE=   10.0000000
   &gt;  for 10            1 :integer
   &gt;20
   &gt; VALUE=   20.0000000
   &gt;  for 20            1 :integer
   &gt;20.
   &gt; VALUE=   20.0000000
   &gt;  for 20.            2 :whole number
   &gt;30.1
   &gt; VALUE=   30.1000004
   &gt;  for 30.1            3 :real number
   &gt;3e1
   &gt; VALUE=   30.0000000
   &gt;  for 3e1            4 :value with exponent
   &gt;1-2
   &gt; VALUE=   9.99999978E-03
   &gt;  for 1-2            4 :value with exponent
   &gt;100.22d-4
   &gt; VALUE=   1.00220004E-02
   &gt;  for 100.22d-4            4 :value with exponent
   &gt;1--2
   &gt; ERROR:        5010 Bad real number in item 1 of list input
   &gt;  ERROR for 1--2           -5 :bad number
   &gt;e
   &gt; ERROR:        5010 Bad real number in item 1 of list input
   &gt;  ERROR for e           -6 :missing leading value before exponent
   &gt;e1
   &gt; ERROR:        5010 Bad real number in item 1 of list input
   &gt;  ERROR for e1           -6 :missing leading value before exponent
   &gt;1e
   &gt; ERROR:        5010 Bad real number in item 1 of list input
   &gt;  ERROR for 1e           -3 :missing exponent
   &gt;1e+
   &gt; ERROR:        5010 Bad real number in item 1 of list input
   &gt;  ERROR for 1e+           -4 :missing exponent after sign
   &gt;1e+2.0
   &gt; ERROR:        5010 Bad real number in item 1 of list input
   &gt;  ERROR for 1e+2.0           -5 :bad number
<P>
</PRE>
<A name=6>

     <H3>AUTHOR</H3>

</A>
<BLOCKQUOTE>
John S. Urban
</BLOCKQUOTE>
<A name=7>

     <H3>LICENSE</H3>

</A>
<BLOCKQUOTE>
Public Domain
</BLOCKQUOTE>
<P><HR>
<TABLE width=100%><TR> <TD width=33%><I>Nemo Release 3.1</I></TD> <TD width=33% align=center>isnumber (3m_strings)</TD> <TD align=right width=33%><I>April 30, 2022</I></TD> </TR></TABLE><FONT SIZE=-1>Generated by <A HREF="http://www.squarebox.co.uk/download/manServer.shtml">manServer 1.08</A> from 3ea8e650-7b0c-4759-b410-edcabe8e807a using man macros.</FONT>
<br><br><center><img src="images/isnumber.gif"></center>
</div>
</div>
</body>
</HTML>
